import json

from rocketmq.client import Producer, Message

from data_models import rocket_mq_data
from rocket_mq_tool import HOST, TOPIC

producer = Producer('PID-XXX')
producer.set_name_server_address(HOST)
producer.start()
print(HOST, TOPIC, json.dumps(rocket_mq_data['result']))
msg = Message(TOPIC)
msg.set_body(json.dumps(rocket_mq_data['result']))
ret = producer.send_sync(msg)
print(ret.status, ret.msg_id, ret.offset)
producer.shutdown()
